import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-08-14
 * Time: 23:31
 */
public class Test82 {
    public static List<Integer> partitionLabels(String s) {
        List<Integer> ret = new ArrayList<>();
        int[] hash = new int[27];
        int n = s.length();
        char[] ch = s.toCharArray();
        for(int i = 0; i < n; i++) {
            hash[ch[i]-'a'] = i;
        }
        int left = 0, right = 0;
        for(int i = 0; i < n; i++) {
            right = Math.max(right,hash[ch[i]-'a']);
            if(right == i) {
                ret.add(right-left+1);
                left = right+1;
            }
        }
        return ret;
    }
    public static void main(String[] args) {
        String s =  "ababcbacadefegdehijhklij";
        List<Integer> ret = partitionLabels(s);
        System.out.println(ret);
    }
}
